import DingtalkEnv from 'dingtalk-javascript-env'
import dingtalk from 'dingtalk-javascript-sdk'
export function setDingHeader() {
  console.log(DingtalkEnv)
  // console.log(DingTalkPC, 'DingTalkPC------')
  const dd = dingtalk.apis
  if (DingtalkEnv.isDingTalk && DingtalkEnv.isWebAndroid) {
    document.addEventListener('backbutton', function(e) {
      e.preventDefault()
      window.history.back(-1)
    })
  }
  if (DingtalkEnv.isDingTalk && DingtalkEnv.isWebiOS) {
    dd.biz.navigation.setLeft({
      control: false, // 是否控制点击事件，true 控制，false 不控制， 默认false
      text: '返回', // 控制显示文本，空字符串表示显示默认文本
      onSuccess: function(result) {
        // window.history.back(-1)
      },
      onFail: function() {
      }
    })
  }
}
